import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'main_page.dart';
import 'menu_page.dart';
import 'my_page.dart';
import 'order_page.dart';
import 'shopping_page.dart';

class IndexPage extends StatefulWidget {
  @override
  _IndexPageState createState() => _IndexPageState();
}

class _IndexPageState extends State<IndexPage> {
  int currentIndex = 0;

  List<Widget> page = [
    MainPage(),
    MenuPage(),
    OrderPage(),
    ShoppingPage(),
    MyPage()
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("MyLuckinCoffee"),
      ),
      body: this.page[this.currentIndex],
      // body: Text("main"),
      // 底部导航栏
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: currentIndex,
        onTap: (index) {
          setState(() {
            currentIndex = index;
          });
        },
        type: BottomNavigationBarType.fixed,
        items: [
          BottomNavigationBarItem(
            label: '首页',
            backgroundColor: Colors.transparent,
            icon: SvgPicture.asset(
              'assets/icons/home.svg',
              // width: 20.0,
              height: 20.0,
            ),
            activeIcon: SvgPicture.asset(
              'assets/icons/home_1.svg',
              // width: 20.0,
              height: 24.0,
            ),
          ),
          BottomNavigationBarItem(
            label: '菜单',
            icon: SvgPicture.asset(
              'assets/icons/order.svg',
              // width: 20.0,
              height: 20.0,
            ),
            activeIcon: SvgPicture.asset(
              'assets/icons/order_1.svg',
              // width: 20.0,
              height: 24.0,
            ),
          ),
          BottomNavigationBarItem(
            label: '订单',
            icon: SvgPicture.asset(
              'assets/icons/menu.svg',
              // width: 20.0,
              height: 20.0,
            ),
            activeIcon: SvgPicture.asset(
              'assets/icons/menu_1.svg',
              // width: 20.0,
              height: 24.0,
            ),
          ),
          BottomNavigationBarItem(
            label: '购物车',
            icon: SvgPicture.asset(
              'assets/icons/shopping.svg',
              // width: 20.0,
              height: 20.0,
            ),
            activeIcon: SvgPicture.asset(
              'assets/icons/shopping_1.svg',
              // width: 20.0,
              height: 24.0,
            ),
          ),
          BottomNavigationBarItem(
            label: '我的',
            icon: SvgPicture.asset(
              'assets/icons/my.svg',
              // width: 20.0,
              height: 20.0,
            ),
            activeIcon: SvgPicture.asset(
              'assets/icons/my_1.svg',
              // width: 20.0,
              height: 24.0,
            ),
          ),
        ],
      ),
    );
  }
}
